package com.core.microBlogs.sina
{
	import com.core.microBlogs.sina.api.account.DoAccount;
	import com.core.microBlogs.sina.api.oauth.DoOauth;

	public class SinaWeiboAPI
	{
		public static const NAME:String = "sina";
		
		private var _dataHandler:Function;
		private var _errorHandler:Function;
		private var _doOauth:DoOauth;
		private var _doAccount:DoAccount;
//		private var _doTimeline:DoTimeline;
//		private var _doTweet:DoTweet;
//		private var _doPrivMsg:DoPrivateMsg;
//		private var _doSearch:DoSearch;
//		private var _doTrends:DoTrends;
		
		public function SinaWeiboAPI(dataHandler:Function, errorHandler:Function)
		{
			this._dataHandler = dataHandler;
			this._errorHandler = errorHandler;
			
			_doOauth = new DoOauth(preDataHandler, preErrorHandler);
//			_doTimeline = new DoTimeline(preDataHandler, preErrorHandler);
//			_doTweet = new DoTweet(preDataHandler, preErrorHandler);
			_doAccount = new DoAccount(preDataHandler, preErrorHandler);
//			_doPrivMsg = new DoPrivateMsg(preDataHandler, preErrorHandler);
//			_doSearch = new DoSearch(preDataHandler, preErrorHandler);
//			_doTrends = new DoTrends(preDataHandler, preErrorHandler);
		}
		
		//申请授权
		public function getRequestToken():void {
			_doOauth.getRequestToken();
		}
		
		//跳转到授权页面
		public function authRequestToken():void{
			_doOauth.authRequestToken();
		}
		
		//交换access_token
		public function getAccessToken():void{
			_doOauth.getAccessToken();
		}
		
//		//时间线
//		//主页时间线
//		public function getHomeTimeline(pageFlag:int, pageTime:int, reqnum:int, format:String = "json"):void{
//			_doTimeline.getHomeTimeline(pageFlag, pageTime, reqnum, format);
//		}
//		//广播大厅时间线
//		public function getPublicTimeline(pos:int, reqnum:int, format:String = "json"):void{
//			_doTimeline.getPublicTimeline(pos, reqnum, format);
//		}
//		//其他用户时间线
//		public function getUserTimeline(pageFlag:int, pageTime:int, reqnum:int, lastId:int, name:String, format:String = "json"):void{
//			_doTimeline.getUserTimeline(pageFlag, pageTime, reqnum, lastId, name, format);
//		}
//		//@提到我的时间线
//		public function getMentionsTimeline(pageFlag:int, pageTime:int, reqnum:int, lastId:int, format:String = "json"):void{
//			_doTimeline.getMentionsTimeline(pageFlag, pageTime, reqnum, lastId, format);
//		}
//		//话题时间线
//		public function getHTTimeline(httext:String, pageFlag:int, pageinfo:String, reqnum:int, format:String = "json"):void{
//			_doTimeline.getHTTimeline(httext, 0, pageinfo, reqnum, format);
//		}
//		//我发表的时间线
//		public function getBroadcastTimeline(pageFlag:int, pageTime:int, reqnum:int, lastId:int, format:String = "json"):void{
//			_doTimeline.getBroadcastTimeline(pageFlag, pageTime, reqnum, lastId, format);
//		}
//		//特别收听到人发表时间线
//		public function getSpecialTimeline(pageFlag:int, pageTime:int, reqnum:int, format:String = "json"):void{
//			_doTimeline.getSpecialTimeline(pageFlag, pageTime, reqnum, format);
//		}
//		
//		//微博相关
//		//获取指定微博
//		public function getTShow(id:String, format:String = "json"):void{
//			_doTweet.getTShow(id, format);
//		}
//		//发表一条新微博
//		public function addT(content:String, clientip:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.addT(content, clientip, jing, wei, format);
//		}
//		//删除一条微博
//		public function delT(id:String, format:String = "json"):void{
//			_doTweet.delT(id, format);
//		}
//		//转播一条微博
//		public function reAddT(content:String, clientip:String, reid:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.reAddT(content, clientip, reid, jing, wei, format);
//		}
//		//回复一条微博
//		public function replyT(content:String, clientip:String, reid:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.replyT(content, clientip, reid, jing, wei, format);
//		}
//		//发布图片微博
//		public function addPic(content:String, clientip:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.addPic(content, clientip, jing, wei, format);
//		}
//		//获取转播或点评数 
//		//ids:各ID之间用","连接
//		//Flag:0 获取转发计数，1点评计数 2 两者都取
//		public function getReCount(ids:String, flag:int = 2, format:String = "json"):void{
//			_doTweet.getReCount(ids, flag, format);
//		}
//		//获取指定微博的转播或评论列表
//		public function getReList(rootId:String, flag:int = 2, pageFlag:int = 0, pageTime:Number = 0, reqnum:int = 20, twitterId:String = "0", format:String = "json"):void{
//			_doTweet.getReList(rootId, flag, pageFlag, pageTime, reqnum, twitterId, format);
//		}
//		//点评一条微博
//		public function comment(content:String, clientip:String, reid:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.comment(content, clientip, reid, jing, wei, format);
//		}
//		//发表音乐微博
//		public function addMusic(content:String, clientip:String, url:String, title:String, author:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.addMusic(content, clientip, url, title, author, jing, wei, format);
//		}
//		//发表视频微博
//		public function addVideo(content:String, clientip:String, url:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.addVideo(content, clientip, url, jing, wei, format);
//		}
//		//获取视频信息
//		public function getVideoInfo(url:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doTweet.getVideoInfo(url, jing, wei, format);
//		}
//		
//		//用户相关
//		//获取用户信息
//		public function getUserInfo(format:String = "json"):void{
//			_doAccount.getUserInfo(format);
//		}
//		//更新用户信息
//		public function updateUserInfo(nick:String, sex:int, year:int, month:int, day:int, 
//									   countrycode:int, provincecode:int, citycode:int, 
//									   introduction:String, format:String = "json"):void{
//			_doAccount.updateUserInfo(nick, sex, year, month, day, countrycode, provincecode, citycode, introduction, format);
//		}							   
//		//更新用户头像
//		public function updateUserHeadImg(format:String = "json"):void{
//			_doAccount.updateUserHeadImg(format);
//		}
//		//获取其他人资料
//		public function getOtherUserInfo(name:String, format:String = "json"):void{
//			_doAccount.getOtherUserInfo(name, format);
//		}
//		
//		//私信相关
//		//发送私信
//		public function addPrivMsg(content:String, clientip:String, name:String, jing:String = null, wei:String = null, format:String = "json"):void{
//			_doPrivMsg.addPrivMsg(content, clientip, name, jing, wei, format);
//		}
//		//删除私信
//		public function delPrivMsg(id:String, format:String = "json"):void{
//			_doPrivMsg.delPrivMsg(id, format);
//		}
//		//收件箱
//		public function getPrivateRecv(pageFlag:int, pageTime:int, reqnum:int, lastid:int, format:String = "json"):void{
//			_doPrivMsg.getPrivateRecv(pageFlag, pageTime, reqnum, lastid, format);
//		}
//		//发件箱
//		public function getPrivateSend(pageFlag:int, pageTime:int, reqnum:int, lastid:int, format:String = "json"):void{
//			_doPrivMsg.getPrivateSend(pageFlag, pageTime, reqnum, lastid, format);
//		}
//		
//		//搜索相关
//		//搜索用户
//		public function searchUser(keyword:String, pagesize:int, page:int, format:String = "json"):void{
//			_doSearch.searchUser(keyword, pagesize, page, format);
//		}
//		//搜索微博
//		public function searchT(keyword:String, pagesize:int, page:int, format:String = "json"):void{
//			_doSearch.searchT(keyword, pagesize, page, format);
//		}
//		//搜索用户通过标签
//		public function searchUserByTag(keyword:String, pagesize:int, page:int, format:String = "json"):void{
//			_doSearch.searchUserByTag(keyword, pagesize, page, format);
//		}
//		
//		//热度，趋势
//		public function getTrendsHT(pos:int, reqnum:int, type:int = 3, format:String = "json"):void{
//			_doTrends.getTrendsHT(pos, reqnum, type, format);
//		}
//		
		//账户相关
		public function verifyCredentials(format:String = "json"):void{
			_doAccount.verifyCredentials(format);
		}
		
		public function getRateLimitStatus(format:String = "json"):void{
			_doAccount.getRateLimitStatus(format);
		}
		
		private function preDataHandler(cmd:String, params:Object):void{
			_dataHandler(cmd, params);
		}
		
		private function preErrorHandler(errorParams:Object):void{
			_errorHandler(errorParams);
		}
	}
}